package com.rtx.wms.std.job.cc;

import java.util.List;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.rtx.api.annotation.RtxJobAnnotation;
import com.rtx.api.quartz.job.BaseJob;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.common.service.CommonService;
import com.rtx.wms.std.handler.cc.finish.CCFinishHandler;

@Component
@DisallowConcurrentExecution
@RtxJobAnnotation(jobName = "CcFinishJob",description = "盘点上传写入中间表",cron = "0 0/1 * * * ?")
public class CcFinishJob implements BaseJob {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private CCFinishHandler ccFinishHandler;

    @Autowired
    private CommonService commonService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        //激活的仓库
        List<String> whseidList = commonService.selectActiveWhseidNotEnterprise(WmsConstant.ENTERPRISE);
        for(String whseid : whseidList){
            try {
            	ccFinishHandler.handlerOrdersFinish(whseid);
            } catch (Exception e) {
                logger.error("仓库{}盘点上传写入中间表异常",whseid,e);
            }
        }
    }
}
